Dice Roll Simulator code

#include #include // for rand() and srand() #include // for time() int main() { // Seed the random number generator with current time std::srand(static_cast(std::time(nullptr))); char choice; std::cout << "🎲 Welcome to the Dice Roll Simulator!\n"; do { int diceRoll = std::rand() % 6 + 1; // Random number between 1 and 6 std::cout << "You rolled a " << diceRoll << "!\n"; std::cout << "Roll again? (y/n): "; std::cin >> choice; } while (choice == 'y' || choice == 'Y'); std::cout << "Thanks for playing!\n"; return 0; }

Code output

🎲 Welcome to the Dice Roll Simulator! You rolled a 4! Roll again? (y/n): y You rolled a 2! Roll again? (y/n): y You rolled a 6! Roll again? (y/n): n Thanks for playing!